package Homework05;

import java.util.ArrayList;
import java.util.Collections;
import java.util.TreeMap;

public class DaPai {
public static void main(String[] args) {
		
		ArrayList<Integer> poker=new ArrayList<>();
		TreeMap<Integer,String> hashMap = new TreeMap<Integer,String>();
		String[] colors={"♠","♥","♦","♣"};
		String[] numbers={"2","A","K","Q","J","10","9","8","7","6","5","4","3"};
		
		
		hashMap.put(0,"JOKER");
		hashMap.put(1,"joker");
		
		int k = 2;
		for(String number:numbers){
			for(String color:colors){
				hashMap.put(k, color+number);
				k++;
			}
		}
		for(int j=0;j<54;j++){
			poker.add(j);
		}
		System.out.println(poker);
		System.out.println(hashMap);
		
		Collections.shuffle(poker);
		
		System.out.println(poker);
		
		Player p1 = new Player();p1.setName("张三");
		Player p2 = new Player();p2.setName("李四");
		Player p3 = new Player();p3.setName("王五");
		ArrayList<Integer> dipai=new ArrayList<>();
		
		
		for(int i=0;i<poker.size();i++){
			
			int p=poker.get(i);
			if(i>=51){
				dipai.add(p);
			}else if(i%3==0){
				p1.getPoker().add(p);
			}else if(i%3==1){
				p2.getPoker().add(p);
			}else if(i%3==2){
				p3.getPoker().add(p);
			}
		}
		
		Collections.sort(p1.getPoker());
		Collections.sort(p2.getPoker());
		Collections.sort(p3.getPoker());
		Collections.sort(dipai);
		
		
		System.out.println(p1.getName()+"的牌：");
		for(int pi1 :p1.getPoker()){
			System.out.print(hashMap.get(pi1)+" ");
		}
		System.out.println();
		System.out.println(p2.getName()+"的牌：");
		for(int pi2 :p2.getPoker()){
			System.out.print(hashMap.get(pi2)+" ");
		}
		System.out.println();
		System.out.println(p3.getName()+"的牌：");
		for(int pi3 :p3.getPoker()){
			System.out.print(hashMap.get(pi3)+" ");
		}
		System.out.println();
		System.out.println("底牌：");
		for(int dp :dipai){
			System.out.print(hashMap.get(dp)+" ");
		}
		System.out.println();
		
	}
	
}
